package com.weme.common.view

import android.content.Context
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView

class ScaleTransitionPagerTitleView(context: Context?) : ColorTransitionPagerTitleView(context) {

    private var listener: OnTitleSelectListener? = null

    interface OnTitleSelectListener {
        fun onTitleSelect(index: Int)
        fun onTitleDeselect(index: Int)
    }

    fun setTitleSelectListener(listener: OnTitleSelectListener?) {
        this.listener = listener
    }

    override fun onEnter(index: Int, totalCount: Int, enterPercent: Float, leftToRight: Boolean) {
        super.onEnter(index, totalCount, enterPercent, leftToRight) // 实现颜色渐变
        //        setScaleX(minScale + (1.0f - minScale) * enterPercent);
        //        setScaleY(minScale + (1.0f - minScale) * enterPercent);
    }

    override fun onLeave(index: Int, totalCount: Int, leavePercent: Float, leftToRight: Boolean) {
        super.onLeave(index, totalCount, leavePercent, leftToRight) // 实现颜色渐变
        //        setScaleX(1.0f + (minScale - 1.0f) * leavePercent);
        //        setScaleY(1.0f + (minScale - 1.0f) * leavePercent);
    }

    override fun onSelected(index: Int, totalCount: Int) {
        super.onSelected(index, totalCount)
        if (listener != null) {
            listener!!.onTitleSelect(index)
        }
    }

    override fun onDeselected(index: Int, totalCount: Int) {
        super.onDeselected(index, totalCount)
        if (listener != null) {
            listener!!.onTitleDeselect(index)
        }
    }
}